<?php

namespace App\Models\Scm;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UnitRelation extends Model
{
    use HasFactory;
    public $timestamps = FALSE;
    protected $table = 'biz_unit_relation';
    protected $fillable = ['unit', 'kingdee_unit', 'kingdee_unit_name', 'del_flag'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
    }

    public function findRowByKingdeeUnit($kingdee_unit){
        return self::where('kingdee_unit', $kingdee_unit)->first();
    }

    public function findRowIfExist($kingdee_unit, $kingdee_unit_name){
        return self::where('kingdee_unit', $kingdee_unit)->where('kingdee_unit_name', $kingdee_unit_name)->first();
    }

    public function insertOne($params){
        return self::create($params);
    }
}
